#include <WinTen.h>
#include <Windows.h>
#include <extend.h>

#define BLACK_PEN  7

//---------------------------------------------------------------------------//

void WndDrawBox( HDC hDC, RECT * rct, HPEN hPUpLeft, HPEN hPBotRit )
{
   HPEN hOldPen = SelectObject( hDC, hPUpLeft );
   POINT pt;

   MoveToEx( hDC, rct->left, rct->bottom, &pt );
   LineTo( hDC, rct->left, rct->top );
   LineTo( hDC, rct->right, rct->top );
   SelectObject( hDC, hPBotRit );

   MoveToEx( hDC, rct->left, rct->bottom, &pt );
   LineTo( hDC, rct->right, rct->bottom );
   LineTo( hDC, rct->right, rct->top - 1 );
   SelectObject( hDC, hOldPen );
}

//---------------------------------------------------------------------------//

void WindowBoxIn( HDC hDC, RECT * pRect )
{
   HPEN hGray  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
   HPEN hWhite = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );

   WndDrawBox( hDC, pRect, hGray, hWhite );

   DeleteObject( hGray );
   DeleteObject( hWhite );
}

//---------------------------------------------------------------------------//

void WindowBox( HDC hDC, RECT * pRect )
{
   HPEN hGray  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
   HPEN hWhite = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );

   WndDrawBox( hDC, pRect, hWhite, hGray );

   DeleteObject( hGray );
   DeleteObject( hWhite );
}

//---------------------------------------------------------------------------//

void WindowRaised( HDC hDC, RECT * pRect )
{
   HPEN hGray  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
   HPEN hWhite = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );

   WndDrawBox( hDC, pRect, hWhite, hGray );

   DeleteObject( hGray );
   DeleteObject( hWhite );
}

//---------------------------------------------------------------------------//

CLIPPER WNDBOXIN() // hDC, nTop, nLeft, nBottom, nRight
{
   RECT rct;

   rct.top    = _parni( 2 );
   rct.left   = _parni( 3 );
   rct.bottom = _parni( 4 );
   rct.right  = _parni( 5 );

   WindowBoxIn( ( HDC ) _parnl( 1 ), &rct );
}

//---------------------------------------------------------------------------//

CLIPPER WNDBOX() // ( hDC, nTop, nLeft, nBottom, nRight )
{
   RECT rct;

   rct.top    = _parni( 2 );
   rct.left   = _parni( 3 );
   rct.bottom = _parni( 4 );
   rct.right  = _parni( 5 );

   WndDrawBox( ( HDC ) _parnl( 1 ), &rct,
               GetStockObject( BLACK_PEN ),
               GetStockObject( BLACK_PEN ) );
}

//---------------------------------------------------------------------------//

CLIPPER WNDRAISED()  // ( hWnd, hDC )
{
   RECT rct;

   GetClientRect( ( HWND ) _parnl( 1 ), &rct );
   --rct.bottom;
   --rct.right;

   WindowRaised( ( HDC ) _parnl( 2 ), &rct );
}

//---------------------------------------------------------------------------//

CLIPPER BARPAINT()  // ( hWnd, hDC )
{
   HWND hWnd = ( HWND ) _parnl( 1 );
   HDC  hDC  = ( HDC )  _parnl( 2 );
   RECT rct;
   HPEN hGray   = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
   HPEN hOldPen = SelectObject( hDC, hGray );
   POINT pt;

   GetClientRect( hWnd, &rct );

   if( ! GetParent( GetParent( hWnd ) ) || ! IsZoomed( GetParent( hWnd ) ) )
   {
      MoveToEx( hDC, rct.left, rct.top, &pt );
      LineTo( hDC, rct.right, rct.top );
      rct.top++;
   }
   SelectObject( hDC, hOldPen );

   --rct.bottom;
   --rct.right;

   WindowRaised( hDC, &rct );
   DeleteObject( hGray );
}

//---------------------------------------------------------------------------//

CLIPPER WNDBOXRAIS()  // ED()  //  hDC, nTop, nLeft, nBottom, nRight
{
   RECT rct;

   rct.top    = _parni( 2 );
   rct.left   = _parni( 3 );
   rct.bottom = _parni( 4 );
   rct.right  = _parni( 5 );

   WindowRaised( ( HDC ) _parnl( 1 ), &rct );
}

//---------------------------------------------------------------------------//
